﻿///////////////////////////////////////////////////////////////////////////////
// File:        ConnectionFactory.cc
// Author:      671643387@qq.com
// Description:
///////////////////////////////////////////////////////////////////////////////

#include <cassert>
#include <boost/bind.hpp>

#include "nio/net/ConnectionFactory.hpp"
using namespace nio::net;

ConnectionFactory::ConnectionFactory()
: connPool_(512)
{

}

ConnectionFactory::~ConnectionFactory()
{

}

ConnectionPtr ConnectionFactory::create(sock_t sock, unsigned int isSize, unsigned int osSize)
{
    return ConnectionPtr(connPool_.construct(sock, isSize, osSize),
        boost::bind(&ConnectionFactory::destroy, this, _1));
}

void ConnectionFactory::destroy(Connection* conn)
{
    assert(conn);
    connPool_.destroy(conn);
}


